package timgmbh.monopoly.general;

import java.util.ArrayList;
import java.util.List;

public class Config {
	
	//********************************************************************************************************************
	//********************************************************************************************************************
	//********************************************************************************************************************
	// DECLARATION
		//of Database variables
	public static final String DB_DRIVER = "org.h2.Driver";
	public static final String DB_DATABASE_URL = "jdbc:h2:~/workspace/Monopoly/db/monopolyDB";
	public static final String DB_CATALOG = "MONOPOLYDB";
	public static final String DB_SCHEMA = "MONOPOLY";
	public static final String DB_USER = "sa";
	public static final String DB_PASS = "";
	
		//of lists
	public static List<String> publicModules;
	public static List<String> privateModules;
	public static List<String> adminModules;
	
		//of paths
	private static final String GFX_PATH = "gfx/";
	private static final String CSS_PATH = "styles/";
	private static final String JS_PATH = "js/";
	public static final String URL="http://localhost:8080/MonopolyApp/";
	
	//********************************************************************************************************************
	//********************************************************************************************************************
	//********************************************************************************************************************
	// DEBUG
	
	public static final Boolean DEBUG_DATABASE = true;
	
	//********************************************************************************************************************
	//********************************************************************************************************************
	//********************************************************************************************************************
	// INIT (replaces constructor)
	
	private static void initModuleTable() {
		//Creation of new Array-lists
		publicModules = new ArrayList<String>();
		privateModules = new ArrayList<String>();
		adminModules = new ArrayList<String>();
		
		//Adding of modules to list
			//public modules
		publicModules.add("HOME");
		publicModules.add("REGISTER");
		publicModules.add("TEST");
		publicModules.add("LOGOUT");
		publicModules.add("LEADERBOARD");
			//private modules
		privateModules.add("PROFILE");
		privateModules.add("GAMELOUNGE");
		privateModules.add("GAMEPROFILE");
		privateModules.add("PLAYINGFIELD");
			//admin modules
		adminModules.add("ADMINHOME");
	}
	
	//********************************************************************************************************************
	//********************************************************************************************************************
	//********************************************************************************************************************
	// PUBLIC FUNCTIONS
	
	//Check, to which category the site belongs (public, private, admin)
	public static boolean isPublicModule(String s) {
		//if list is not yet created: initialization of list
		if (publicModules == null) initModuleTable(); 
		
		//returns true, if the module is public
		return publicModules.contains(s.toUpperCase());
	}
	public static boolean isPrivateModule(String s) {
		//if list is not yet created: initialization of list
		if (publicModules == null) initModuleTable();
		
		//returns true, if the module is private
		return privateModules.contains(s.toUpperCase());
	}
	public static boolean isAdminModule(String s) {
		//if list is not yet created: initialization of list
		if (adminModules == null) initModuleTable(); 
		
		//returns true, if the module is admin
		return adminModules.contains(s.toUpperCase());
	}
	
	
	//Getter-methods for displaying HTML-document
	//returns gfx-path
	public static String getGfxPath(){
		return (URL + GFX_PATH);
	}

	//returns css-path
	public static String getCssPath(){
		return (URL + CSS_PATH);
	}
	
	//returns js-path
	public static String getJsPath(){
		return (URL + JS_PATH);
	}
	
	//returns url
	public static String geturl(){
		return URL;
	}
}
